// /*
//  * @Author: WanYiMing
//  * @Date:2024-05-21-18:06
//  * @Description:
//  */

using Code.Core.CoreBaseClass;
using Code.GameLogic.Common;
using Code.GameLogic.Common.Event;
using Code.GameLogic.GameCamera;
using Code.GameLogic.Map.Controller;
using Code.GameLogic.Monster.Controller;
using Code.GameLogic.XianJian.Controller;
using Code.GameLogic.XianJian.UI;
using Code.GameLogic.World.UI;
using Code.Utility;
using QFramework;
using UnityEngine;

namespace Code.GameLogic
{
    public class MainAppLoader:BaseController
    {
        private GameObject _mainUI;
        
        private void Awake()
        {
            _mainUI = GameObject.Find("MainUI");


            //挂载公共组件
            CheckAndInitComponent<GlobalCommon>(gameObject);
            CheckAndInitComponent<GlobalFunction>(gameObject);
            CheckAndInitComponent<GlobalEvent>(gameObject);
            
            //挂载Manager
            CheckAndInitComponent<MapManager>(gameObject);
            CheckAndInitComponent<WayPointManager>(gameObject);
            CheckAndInitComponent<MonsterManager>(gameObject);
            CheckAndInitComponent<XianJianManager>(gameObject);
            
            //挂载Controller
            CheckAndInitComponent<CameraController>(Camera.main!.gameObject);
            
            //挂载UI
            CheckAndInitComponent<XianJianListUI>(_mainUI);
            CheckAndInitComponent<WorldUI>(_mainUI);

            
        }
        
        private void CheckAndInitComponent<T>(GameObject checkGameObject) where T : Component
        {
            GameObjectUtils.CheckComponent<T>(checkGameObject);
        }


        public override IArchitecture GetArchitecture()
        {
            return MainApp.Interface;
        }
    }
}